//
// Created by draw on 19-5-30.
//

#include "Clock.h"

Clock Ck;

extern "C"
void TIM5_IRQHandler(void)
{
    TIM5->SR = 0;
    Ck.Gt++;
}


void Clock::Run()
{
    Gt = 0;
    TIM = TIM5;

    TIM->Run(84, 0xFFFFFFFF);
}

u64 Clock::TimeInUs()
{
    union
    {
        u64 Tmp;
        u32 Da[2];
    };

    Da[0]=Gt;
    Da[1]=TIM->CNT;

    return Tmp;
}
